#include<bits/stdc++.h>
using namespace std;
const int N = 5e6+10;
const int INF = 0x3f3f3f3f;

int n,p;
int a[N],b[N];

void insert(int x,int y,int z) {
    b[x] += z;
    b[y+1] -= z;
}

int main() {
    cin>>n>>p;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        b[i] = a[i] - a[i-1];
    }
    while(p--) 
    {
        int x,y,z;
        cin>>x>>y>>z;
        insert(x,y,z);
    }
    int min_ = INF;
    for(int i=1;i<=n;i++) {
        a[i] = b[i] + a[i-1];
        min_ = min(a[i],min_);
    }
    cout<<min_<<endl;
    return 0;
}